@extends('layouts.app')
@section('title')个人中心-@parent @endsection
@section('description')@parent @endsection
@section('content')
    <div class="container">
        <div class="row">
            <div class="col-lg-3 col-md-3">
                <div class="card">
                    <div class="card-body links">
                        <div class="text-center">作者：{{$user->name ?? ''}}</div>
                        <hr>
                        <div class="media">
                            <div align="center">
                                <a href="">
                                    <img src="{{isset($user)?url($user->avatar):''}}" class="img-thumbnail img-fluid">
                                </a>
                            </div>
                        </div>
                        <hr>
                        <div class="media-body">
                            <h4><strong>个人简介</strong></h4>
                            <p>{{$user->introduction ?? '这个人很懒，什么都没写'}}</p>
                        </div>
                        <hr>

                        <div class="media-body">
                            <h4><strong>注册于</strong></h4>
                            <p>{{isset($user)?$user->created_at->diffForHumans():''}}</p>
                        </div>

                    </div>
                </div>
            </div>
            <div class="col-lg-9 col-md-9 topic-list">
                <div class="card">
                    <div class="card-body">
                        <h3 class="card-title">{{$user->name}} <small class="font-weight-light">{{$user->email}}</small></h3>

                    </div>
                </div>

                <div class="card" style="margin-top: 20px">

                    <div class="card-body links">
                        <ul class="nav nav-tabs">
                            <li class="nav-item">
                                <a class="nav-link {{!isset($_GET['tab'])?'active':'' }}" href="{{route('user',[$user->id])}}">Ta 的话题</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav-link {{isset($_GET['tab']) && $_GET['tab'] == 'replies'?'active':''}}" href="{{route('user',[$user->id])}}?tab=replies">Ta 的回复</a>
                            </li>
                        </ul>
                        <ul class="list-group">
                            @if(!isset($_GET['tab']))
                                @if (isset($topics) && !$topics->isEmpty())
                                    @foreach($topics as $topic)
                                        <li class="list-group-item">
                                            <a href="{{route('topics.show',[$topic->category->id,$topic->id])}}">{{$topic->title ?? ''}}</a>
                                            <span class="meta pull-right">
                                                {{$topic->reply_count ?? ''}} 回复
                                                <span> ⋅ </span>
                                                {{$topic->created_at->diffForHumans()}}
                                            </span>
                                        </li>
                                    @endforeach
                                    {{$topics->links()}}
                                @else
                                    <li class="list-group-item">
                                        您还没有创建话题，赶紧去创建一个吧~
                                    </li>
                                @endif
                            @endif

                            @if(isset($_GET['tab']) && $_GET['tab'] == 'replies')
                                @if (isset($replies) && !$replies->isEmpty())
                                    @foreach($replies as $reply)
                                        <li class="list-group-item">
                                            <a href="{{route('topics.show',[$reply->topic->category->id,$reply->topic->id])}}">
                                                {{$reply->topic->title}}
                                            </a>
                                            <div class="rpely-content" style="margin: 6px 0px;">
                                                <p>{{\gl\clear_str_ellipsis($reply->content,100)}}</p>
                                            </div>
                                            <div class="meta">
                                                <span aria-hidden="true" class="glyphicon glyphicon-time"></span> 回复于 {{$reply->created_at->diffForHumans()}}
                                            </div>
                                        </li>
                                    @endforeach
                                    {{$replies->appends(['tab' => $_GET['tab']])->links()}}
                                @else
                                    <li class="list-group-item">
                                        您还没有评论过别人的话题~
                                    </li>
                                @endif
                            @endif
                        </ul>
                    </div>


                </div>

            </div>
        </div>
    </div>
@endsection

@section('scripts')
    <script>
        new Vue({
            el:'#app',
            mounted() {

            },
            data() {
                return {

                }
            },
            methods:{

            }
        });
    </script>
@endsection

